<form class="layui-form seller-form" action="">
    <div class="layui-form-item">
        <div class="layui-inline">
            <div class="layui-input-inline seller-inline-3">
                <input type="text" name="manage_name" lay-verify="title" placeholder="User Name" autocomplete="off"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <div class="layui-input-inline seller-inline-3">
                <input type="text" name="desc" lay-verify="title" placeholder="Desc" autocomplete="off"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <div class="layui-input-inline seller-inline-4">
                <input type="text" name="datetime" id="datetime" placeholder="start_time _ end_time" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-sm" lay-submit lay-filter="*"><i class="iconfont icon-chaxun"></i>Search</button>
            </div>
        </div>
    </div>
</form>
<div class="table-body">
    <table id="balanceTable" lay-filter="balanceTable"></table>
</div>
<script>
    layui.use(['form', 'laydate', 'table',], function () {
        var laydate = layui.laydate,
            form = layui.form,
            table = layui.table; //表格
        //时间插件
        laydate.render({
            elem: '#datetime',
            range: '_',
            format: 'yyyy-MM-dd'
        });
        table.render({
            elem: '#balanceTable',
            height: 'full-99',
            cellMinWidth: '80',
            totalRow: true,
            method: 'post',
            url: "{:url('balance/manage')}",
            toolbar: '#toolbar', //开启头部工具栏，并为其绑定左侧模板
            defaultToolbar: ['filter', 'exports'],
            id: 'balanceTable',
            cols: [[
                { type: 'numbers'},
                { field: 'username',  align: 'center', title: 'ManageName',width: 200},
                { field: '', align: 'center', title: 'Type' ,width:200,
                    templet: function (d) {
                        const type_name = d.type;
                        if(type_name == 1){
                            return '<font color="red">Debit</font>';
                        }else{
                            return '<font color="green">Credit</font>';
                        }
                    }
                },
                {field: 'amount', title: 'Amount($)', align:"right",
                    style:'color:#FF5722;font-weight:bold',width:200,totalRow: true
                },
                { field: 'balance', align: 'right', title: 'Balance($)' ,
                    style:'color:#FF5722;font-weight:bold',width:200},
                { field: 'remark',  align: 'center', title: 'Description'},
                { align: 'center', title: 'Initiated Date',width:200,
                    templet: function (d) {
                        return layui.util.toDateString(d.ctime * 1000, "yyyy-MM-dd HH:mm:ss");
                    }
                }
            ]],
            page: true,
            limit: 20,
            limits: [20, 50, 100,1000,2000],
        });
        form.on('submit(*)', function (data) {
            layui.table.reload('balanceTable', {
                where: data.field
                , page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
            return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        });
    });
</script>